module FourBitFullAdder(
	input  [3:0] A,
	input  [3:0] B,
	input        Cin,
	output [3:0] Sum,
	output       Cout
);

wire [2:0] carry;

OneBitFullAdder FA0(
	.A(A[0]),
	.B(B[0]),
	.Cin(Cin),
	.Sum(Sum[0]),
	.Cout(carry[0])
);

OneBitFullAdder FA1(
	.A(A[1]),
	.B(B[1]),
	.Cin(carry[0]),
	.Sum(Sum[1]),
	.Cout(carry[1])
);

OneBitFullAdder FA2(
	.A(A[2]),
	.B(B[2]),
	.Cin(carry[1]),
	.Sum(Sum[2]),
	.Cout(carry[2])
);

OneBitFullAdder FA3(
	.A(A[3]),
	.B(B[3]),
	.Cin(carry[2]),
	.Sum(Sum[3]),
	.Cout(Cout)
);


endmodule

module OneBitFullAdder (
	input A,
	input B,
	input Cin,
	output Sum,
	output Cout
);

	assign Sum = (~A & ~B & Cin) | 
		(~A & B & ~Cin) | 
		(A & ~B & ~Cin) | 
		(A & B & Cin);

	assign Cout = (A & B) | (A & Cin) | (B & Cin);

endmodule

